package com.lagou.api;

import org.apache.kudu.client.*;

/*
1、获取client
2、获取Scanner
3、从Scanner中循环遍历数据
 */
public class SelectDemo {
    public static void main(String[] args) {
        String masterAddresses="zb26105";
        KuduClient client = new KuduClient.KuduClientBuilder(masterAddresses).defaultSocketReadTimeoutMs(5000).build();

        try {
            KuduTable stuTable = client.openTable("student");
            KuduScanner scanner = client.newScannerBuilder(stuTable).build();
            while(scanner.hasMoreRows()){
                for (RowResult result : scanner.nextRows()) {
                    int id = result.getInt("id");
                    String name = result.getString("name");
                    System.out.println(id +"......"+ name);
                }
            }

        } catch (KuduException e) {
            e.printStackTrace();
        }finally {
            try {
                client.close();
            } catch (KuduException e) {
                e.printStackTrace();
            }
        }

    }
}
